{extend name="public/base" /} {block name="body"}
<div class="ibox float-e-margins">
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li><strong>在线订单列表</strong></li>

	</ol></div>

	{include file="order/top"}
	<div class="ibox-content">
		<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('index',['status'=>$status])}">
		<div class="row">
					<div class="form-group">&nbsp;&nbsp;&nbsp;&nbsp;
													订单类型
						<select name="express_type" class="bank" style="width: 100px;"> 
         				<option value="0">全部订单</option>
                        <option value="1">快递订单</option>
                        <option value="2">O2O订单</option>
                </select>
							订单号<input type="text" id="order_number" name="order_number" value="" placeholder="请输入订单号" class="bank" />
					       	下单时间<input id='start_time' name='start_time'  style="width: 90px;" onclick='WdatePicker()' type='text' placeholder="开始时间" class="bank" />
							<input id='end_time' name='end_time'  style="width: 90px;" onclick='WdatePicker()' type='text' placeholder="结束时间" class="bank" />
							收货人姓名<input type="text" id="receiver" name="receiver" value="" placeholder="请输入收货人姓名" class="bank" />
							手机号<input type="text" id="receiver_mobile" name="receiver_mobile" value="" placeholder="请输入收货人手机" class="bank" />
							<button type="submit" class="btn btn-sm btn-primary"><li class="fa fa-search"> 查询</li></button>
							<a href="{:url('export',['status'=>$status])}" class="btn btn-primary btn-outline">导出订单信息</a></span>
					</div>              
        </div>
        </form>
		<div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <tbody id="list">
                        	{foreach name="list1" item='order'}
                        	<tr><td colspan="10"><span style="font-size:20px ;font-weight:bold;">订单类型:</span>
                        	<span style="font-size:15px ;font-weight:bold; color: #0000CC;">	
                        		{if $order.express_type==1}
                        			快递订单
                        			{elseif $order.express_type==2}
                        			O2O订单
                        			
                        	</span>	
                        			{/if}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        			<span style="font-size:20px ;font-weight:bold; color: #000000;">订单号:</span> 
                        			<span style="font-size:15px ;font-weight:bold; color: #008200;">{$order.sn}</span> 
                        		
                        		
                        				
                        				
                        			<li  style="padding-left: 1000px">
                        				<span style="padding-right:10px;">打印
                        				</span>
                        				
                        					
                        			<a href="{:url('order/index')}" class="fa fa-search"><strong>查看详情</a></strong>
                        			</li>
                        	</td></tr>
                        	 <tr class="long-tr">
	                        	<th>商品名称</th>
	                            <th>单价/数量</th>
	                            <th>购买栏目</th>
	                            <th>用户支付</th>
								<th>买家</th>
	                            <th>下单时间</th>
	                            <th>订单状态</th>
	                            <th>实付金额</th>
	                        </tr>
                        	{foreach name="order['items']" item="ad" key="k" }
                        	<tr>
                        		
                        		<td><img src="{$ad.thumb}"  width="50px"/>{$ad.goods_name}</td>
                        		<td>{$ad.price}<br>{$ad.number}(件)</td>
                        		<td>
                        			{if $ad.goods_lanmu==1}
                        			疯狂抢
                        			{elseif $ad.goods_lanmu==2}
                        			优惠购
                        			{elseif $ad.goods_lanmu==3}
                        			赚积分
                        			{elseif $ad.goods_lanmu==4}
                        			云拼团
                        			{/if}
                        		</td>
                        		<td>{$ad.total_price}</td>
                        		<td>{$ad.username}</td>
                        		<td>{$ad.add_time}</td>
                        		{if condition="$k==0"}
                        			<td rowspan="<?php echo count($order['items']) ?>">{if $order.order_state==1}
                        			待付款
                        			{elseif $order.order_state==2}
                        			拼团中
                        			{elseif $order.order_state==3}
                        			待发货<br />
                        			<a class="btn btn-primary bnt-sm" onclick="show_fh('{$order.id}');">发货</a>
                        			{elseif $order.order_state==4}
                        			已发货
                        			{elseif $order.order_state==5}
                        			已完成
                        			{elseif $order.order_state==6}
                        			已关闭
                        			{/if}
                        			</td>
                        			<td rowspan="<?php echo count($order['items']) ?>">
                        			{$order.pay_price}
                        			</td>
                        		{/if}
                        	</tr>
                        	{/foreach}
                        	<tr></tr>
                        	{/foreach}
                        </tbody>
                    </table>
                    <div style="text-align: right;">
                      {$list->render()}
                    </div>
                </div>
            </div>
            </div>
</div>
<div class="modal-content" id="map-dialog" style="display:none;height: 350px; position:fixed;z-index:1000;background:#fff;left: 35%;top: 20%;width:550px;">
				<div class="modal-header" style="padding: 5px;"><h2>订单发货<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="$('#map-dialog').hide()">×</button></h2></div>
				<div class="modal-body">
					<div id="map-container" class="row" style="margin-left:10px;overflow: hidden; position: relative; z-index: 0;  color: rgb(0, 0, 0); text-align: left;">
						<div class="form-group">
							<label class=" control-label">订单号</label>
							<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
								<span id="sn"></span>
							</div>
						</div>
						<div class="form-group">
							<label class=" control-label">收货人</label>
							<div class="input-group " style="display: inline;padding-left: 30px;">
								<span id="shr"></span>
							</div>
						</div>
						<div class="form-group">
							<label class=" control-label">收货地址</label>
							<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
								<span id="address"></span>
							</div>
						</div>
						<div class="form-group">
							<label class=" control-label">物流公司</label>
							<div class="input-group col-sm-5" style="display: inline;padding-left: 30px;">
								<select id="express">
									<option value="">
										选择物流公司
									</option>
									{foreach name="express" item='exp'}
									<option value="{$exp['value']['no']}">
										{$exp['value']['name']}
									</option>
									{/foreach}
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class=" control-label" style="float: left;">物流单号</label>
							<div class="input-group " style="display: inline;padding-left: 30px;">
								<input type="text" style="width: 250px;float: left;margin-left: 30px;" id="express_no" name="express_no" value="" placeholder="请输入物流单号" class="form-control" />
							</div>
					   </div>
					</div>
					<br />
					<div class="modal-footer ">
							<a  class="btn btn-default" data-dismiss="modal" onclick="javascript:$('#map-dialog').hide()">取消</a><a onclick="fahuo()"  class="btn btn-primary ">确认</a>
					</div>
				</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
	if({$status}==0){	
		$("#li-bar-si").addClass("active");
	}
	if({$status}==1){
		$("#li-bar-site").addClass("active");
	  }
	if({$status}==2){
		$("#li-bar-sms").addClass("active");
	  }
	if({$status}==3){
		$("#li-bar-pay").addClass("active");
	  }
	if({$status}==4){
		$("#li-bar-log").addClass("active");
	  }
	if({$status}==5){
		$("#li-bar-wechat").addClass("active");
	  }
	if({$status}==6){
		$("#li-bar-three").addClass("active");
	}
function fahuo(){
	var sn=$("#sn").text();
	var express=$("#express").val();
	var express_no=$("#express_no").val();
	if(express==""){
		layer.msg("请选择物流方式");
		return false;
	}
	if(express_no==""){
		layer.msg("请输入物流单号");
		return false;
	}
	$.ajax({
				//请求的url
				//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
				url: 'fahuo',
				//请求的过程中传递过去的参数 json
				data: {
					sn: sn,
					express:express,
					express_no:express_no
				},
				//成功了的回调，并且带有返回值
				success: function(data) {
						layer.msg(data.msg, {
						  icon: 1,
						  time: 1000 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
						  if(data.code == 200) {
						  	$('#map-dialog').hide();
							location.reload();
						  }
						}); 
					
				}
			})
	
}
function show_fh(id){
				$.ajax({
					//请求的url
					//注意，如果我们使用路由器的情况下，我们需要设置一下本地服务器的ip地址
					url: 'getOrderInfo',
					//请求的过程中传递过去的参数 json
					data: {
						order_id: id
					},
					//成功了的回调，并且带有返回值
					success: function(data) {
						if(data.code==200){
							var dt=data.order;
							$("#sn").text(dt.sn);
							$("#shr").text(dt.receiver+" "+dt.receiver_mobile);
							$("#address").text(dt.address);
							
						}else{
							layer.msg("订单不存在");
						}
						
					}
				})
	$("#map-dialog").show();
	
}
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    text-align:center;
    border-radius:5px;
}
li{
	list-style:none;
}

</style>
{/block}
